package cn.stylefeng.guns.modular.robot.controller;

import cn.stylefeng.guns.core.common.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.robot.entity.WalletConfig;
import cn.stylefeng.guns.modular.robot.service.WalletConfigService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("/walletConfig")
public class WalletConfigController extends BaseController {

    private static String PREFIX = "/modular/system/";

    @Resource
    private WalletConfigService walletConfigService;

    @GetMapping("/getWalletConfig")
    @ResponseBody
    public WalletConfig getWalletConfig(@RequestParam("type") Integer type,@RequestParam("imeis") String imeis) {
        return walletConfigService.getWalletConfig(type,imeis);
    }

    @PostMapping("/change")
    public void change(@RequestBody WalletConfig walletConfig) {
        walletConfigService.change(walletConfig);
    }

    @ResponseBody
    @PostMapping("/add")
    public ResponseData add(@RequestBody WalletConfig walletConfig) {
        walletConfigService.add(walletConfig);
        return SUCCESS_TIP;
    }

    @ResponseBody
    @PostMapping("/update")
    public ResponseData update(@RequestBody WalletConfig walletConfig) {
        walletConfigService.update(walletConfig);
        return SUCCESS_TIP;
    }


    @ResponseBody
    @PostMapping("/detail")
    public ResponseData detail(@RequestParam("id") Long id) {
        return walletConfigService.detail(id);
    }

    @GetMapping("/list")
    @ResponseBody
    public LayuiPageInfo list(@RequestParam(value = "imei", required = false) String imei,
                              @RequestParam(value = "wallet", required = false) String wallet,
                              @RequestParam(value = "type", required = false) Integer type,
                              @RequestParam(value = "enable", required = false) Boolean enable,
                              @RequestParam(value = "limit") Long pageSize,
                              @RequestParam(value = "page") Long pageNum) {
        return walletConfigService.list(imei, wallet, type, enable, pageSize, pageNum);
    }

    @RequestMapping("/walletConfigadd")
    public String walletConfig_add() {
        return PREFIX + "walletConfig/walletconfig_add.html";
    }

    @RequestMapping("/walletconfiglist")
    public String walletconfiglist() {
        return PREFIX + "walletConfig/walletconfig.html";
    }

    @RequestMapping("/walletConfigedit")
    public String walletConfig_edit() {
        return PREFIX + "walletConfig/walletconfig_edit.html";
    }

    @RequestMapping("/df")
    public String df() {
        return PREFIX + "df/df.html";
    }

    @RequestMapping("/ds")
    public String ds() {
        return PREFIX + "ds/ds.html";
    }

    @ResponseBody
    @GetMapping("/dsList")
    public LayuiPageInfo dsList(@RequestParam(value = "limit") Long pageSize,
                                @RequestParam(value = "page") Long pageNum) {
        return walletConfigService.dsList(pageNum, pageSize);
    }

    @ResponseBody
    @GetMapping("/dfList")
    public LayuiPageInfo dfList(@RequestParam(value = "limit") Long pageSize,
                                @RequestParam(value = "page") Long pageNum) {
        return walletConfigService.dfList(pageNum, pageSize);
    }
}
